<script>
$(function(){
    // 快速添加
    $('#fast_add').submit(function(){
        var data = $(this).serialize()+'&app=<?php echo APP; ?>&mod=userpost';
        $.post('system.php',data,function(data){
            if (data.state <= 0)
            {
                alert(data.message);
                return false;
            }
			alert(data.message);
            //dialogMessage(data.message,'green');
            location.href = location.href;
			
        },'json');
        return false;
    });
	
    $('.span_now').click(function(){
        var edv = $('.edit_div');
        edv.css('display',edv.css('display') == 'none' ? 'block' : 'none');
    });
	// 修改审核？
    $('img[yesno]').click(function(){
        var obj = $(this);
        $.post('system.php',{app:'<?php echo APP; ?>',mod:'userpost',node_id:$(this).attr('yesno'),act:'set'},function(data){
            if (data.state <= 0)
            {
                alert(data.message);
                return false;
            }
			alert(data.message);
            //dialogMessage(data.message,'green');
            obj.attr('src',data.extra);
        },'json');
    });
	
	// 删除
    $('img[del]').click(function (){
        var uid = $(this).attr('del');
        var nickname = $(this).attr('nickname');
        if(confirm('真的要删除'+nickname+'吗？')) {
            $.getJSON('?app=<?php echo APP; ?>&mod=deleteuser',{uid:uid},function(data){
                if (data.state <= 0)
                {
                    alert(data.message);
                    return false;
                }
				//alert(data.message);
				dialogMessage(data.message,'green');
                $('tr[wparam='+uid+']').remove();
            });
        }
    });
});
</script>
<div class="t_2">
     <div class="fl">所属客户</div>
     <div class="fr add_form"><a href="javascript:;" id="add_table"></a></div>
</div>
<form id="fast_add" onSubmit="return false;">
<div class="order_show" id="info_form">
     <table width="100%" cellpadding="0" cellspacing="0" border="0" class="info_table">
			<tr>
            	<td class="td1" width="15%">选择所属的客户：</td>
				<td><?php echo $this->customer['customer_name']; ?>
                	<input type="hidden" id="customer_id" name="customer_id" value="<?php echo $this->customer['customer_id']; ?>"/>
                </td>
			</tr>
     </table>
</div>
<div class="t_2">
     <div class="fl">下属的用户列表</div>
     <div class="fr add_form"><a href="?app=customer&mod=usermanage&customer_id=<?php echo $this->customer['customer_id']; ?>&opt=add" id="add_table">+添加用户</a></div>
</div>
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="table1">
       <tr>
            <th class="th0">编号</th>
            <th class="th1">用户名称</th>
            <th class="th1">登录名</th>
            <th class="th0">座机</th>
            <th class="th1">手机</th>
            <th class="th1">邮箱</th>
            <th class="th1">地址</th>
            <th class="th1">注册时间</th>
            <th class="th1">审核?</th>
            <th class="th1">操作</th>
       </tr>
       <?php foreach((array)$this->users as $tempuser): ?> 
       <tr wparam="<?php echo $tempuser['leader_id']; ?>">
            <td><?php echo $tempuser['leader_id']; ?></td>
            <td><?php echo $tempuser['realname']; ?></td>
            <td><?php echo $tempuser['username']; ?></td>
            <td><?php echo $tempuser['tel']; ?></td>
            <td><?php echo $tempuser['mobile']; ?></td>
            <td><?php echo $tempuser['email']; ?></td>
            <td><?php echo $tempuser['address']; ?></td>
            <td><?php echo date('Y-m-d H:i',$tempuser['created_time']); ?></td>
             <td><?php echo yesno($tempuser['state']==1,'yesno="'.$tempuser['leader_id'].'"'); ?></td>
            <td>
            <?php echo opt('edit','?app=customer&mod=usermanage&leader_id='.$tempuser['leader_id'].'&opt=edit','title="编辑客户"'); ?>
            <?php echo opt('trash','javascript:;','del="'.$tempuser['leader_id'].'" nickname="'.$tempuser['realname'].'" title="删除" '); ?>
   
            </td>
       </tr>
       <?php endforeach; ?>
</table>
<div class="page_num">
     <div class="fl">
        <span></span>
     </div>
     <div class="fr">
        <p class="cpager">
            <?php echo $this->pager; ?>
        </p>
     </div>
</div>



<div class="line_1"></div>
<div class="edit_tab tab"><div class="bg1"><div class="bg2"><span class="span_now"><?php echo $this->optname; ?></span></div></div></div>
<div class="edit_div" style="display:block;">
    <div class="post_form" id="info_form">
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="info_table">
		<tr>
			<td class="td2">用户名称：</td>
			<td><span><input name="realname" id="realname" value="<?php echo $this->user['realname']; ?>" /></span></td>
		</tr>
        <tr>
			<td class="td2">登录名称：</td>
			<td><span><input name="username" id="username" value="<?php echo $this->user['username']; ?>" /><font color="#848484">登录名,不超过10个字符</font></span></td>
		</tr>
        <tr>
			<td class="td1">密码：</td>
			<td><span><input type="password" name="password" id="password" value="" /><font color="#848484">不超过12个字符</font></span></td>
		</tr>
        <tr>
			<td class="td1">确认密码：</td>
			<td><span><input type="password"  name="chkpassword" id="chkpassword" value="" /><font color="#848484"></font></span></td>
		</tr>
		<tr>
			<td class="td1">座机：</td>
			<td><span><input name="tel" id="tel" value="<?php echo $this->user['tel']; ?>" /><font color="#848484">7或11位纯数字，区号和号码间不能有符号</font></span></td>
		</tr>
        <tr>
			<td class="td1">手机：</td>
			<td><span><input name="mobile" id="mobile" value="<?php echo $this->user['mobile']; ?>" /></span></td>
		</tr>
        <tr>
			<td class="td1">地址：</td>
			<td><span><input name="address" id="address" value="<?php echo $this->user['address']; ?>" /></span></td>
		</tr>
        <tr>
			<td class="td1">电子邮箱：</td>
			<td><span><input name="email" id="email" value="<?php echo $this->user['email']; ?>" /></span></td>
		</tr>
        <tr>
			<td class="td1">佣金：</td>
			<td><span><input name="commision" id="commision" value="<?php echo $this->user['commision']; ?>" /></span></td>
		</tr>
		<tr>
			<td class="td1">备注：</td>
			<td><textarea name="mark" id="mark"><?php echo $this->user['mark']; ?></textarea></td>
		</tr>
		<tr>
			<td colspan="2" style="text-align:center" class="td1">
            	<input type="submit" value="提交"  class="btn1"/>
                 <input type="hidden" id="leader_id" name="leader_id" value="<?php echo $this->user['leader_id']; ?>"/>
                <input type="hidden" id="act" name="act" value="<?php echo $this->opt; ?>"/>
            	<input name="" type="reset" class="btn1" value="重置" />
            </td>
		</tr>
     </table>
</div>
</div>
</form>
